{% extends 'base.html' %}
{% block bar %}
<div class="col-md-9" style=  "justify-content: flex-end;">
            <h1 class="page-header">订单管理页面</h1>
        <div class="panel panel-primary">
                <!-- Default panel contents -->
        <div class="panel-heading">订单明细修改<i class="fa fa-thumb-tack pull-right"></i></div>
            <div class="panel-body">
                <div class="row" style="margin-bottom: 15px">
                    <div class="col-md-4">
                            <div class="input-group">
                            </div><!-
                        </div><!- /input-group -->
                        </div><!-- /.col-md-4 -->
            </div>
        </div>
</div>
{% endblock %}
{% block main%}
    <form action="" method="post">
        {% csrf_token %}

    <p>
             <input type="hidden" name="id" value="{{ order_obj.id }}">
          </p>
          <p>
             <input type="hidden" name="customer_id_id" value="{{ order_obj.customer_id_id }}">
          </p>
           <p>
                &nbsp空间名称：<input type="text" name="space_name" value="{{ order_obj.space_name }}">
            </p>
          <p>&nbsp<label >商品名称：</label>
                <select  id="select" onchange="changefunc()" name="goods_id_id" >
                    {% for goods_obj in goods_list %}
                        {% if  order_obj.goods_id_id  == goods_obj.id %}
                            <option  value={{ goods_obj.id }} selected>{{ goods_obj.goods_name }}</option>

                        {% else %}
                            <option  value={{ goods_obj.id }} >{{ goods_obj.goods_name }}</option>
                        {% endif %}

                    {% endfor %}
            </select>
            </p>
           <p>
                &nbsp规格型号：<input id='goods_type' type="text" name="goods_type" disabled="disabled" value="{{ order_obj.goods_id.goods_type }}">
            </p>
            <p>
                &nbsp单&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp位：<input id='units' type="text" name="unit" disabled="disabled" value="{{ order_obj.goods_id.unit }}">
            </p>
            <p>
                &nbsp单&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp价：<input id='goods_prices' type="text" name="goods_price" disabled="disabled" value="{{ order_obj.goods_id.goods_price }}">
            </p>
            <p>
                &nbsp成交单价：<input type="text" name="deal_unit" value={{ order_obj.deal_unit }} >
            </p>
               <p>
                &nbsp面&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp积：<input type="text" name="area" value={{ order_obj.area }}>
            </p>
              <p>
                &nbsp数&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp量：<input type="text" name="goods_nums" value={{ order_obj.goods_nums }}>
            </p>
            <p>
                &nbsp备&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp注：<input type="text" name="remarks" value="{{ order_obj.remarks }}">
            </p>
            <p>
                &nbsp&nbsp<button type="submit" class="btn">提交</button>
            </p>

    </form>
      <script>
                    function changefunc(){
                        {% for goods_obj in  goods_list%}


                            if  ({{ goods_obj.id }} ==document.getElementById("select").value){

                                document.getElementById("goods_type").value = "{{ goods_obj.goods_type }}";
                                document.getElementById("units").value = "{{ goods_obj.unit }}";
                                document.getElementById("goods_prices").value = "{{ goods_obj.goods_price }}";
                            }

                        {% endfor %}
                    }
      </script>

{% endblock %}
